package com.example.demo.controller;

import com.example.demo.model.bean.ResultInfo;
import com.example.demo.model.bean.User;
import com.example.demo.model.dao.UserDAO;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;

// @RestController = @Controller + @ResponseBody
@RestController
@RequestMapping("/user")
public class UserController {
	
	@Autowired
	private UserService userService;
	
	@GetMapping(value = "/insert")
	public ResultInfo insert(String mobile) {


		User user = userService.insert(mobile);

		ResultInfo info = new ResultInfo();
		info.setData(user);
		HashMap map = new HashMap();
		map.put("msg","登录成功");
		map.put("status","200");
		info.setMeta(map);
		return info; // 此处表示返回值是一个值为“login”的String。不指向界面的原因是类的注解是@RestController
	}
	
	


}
